home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / GAF200B.ZIP / DOC / DEMO.DOC < prev    next >
Encoding:
Text File  |  1994-10-27  |  16.4 KB  |  377 lines

  1. Conventions
  2.   The  following  conventions are used throughout  this
  3.   document.
  4.        'Enter'     means the Enter key  or  the Return
  5.                    key.
  6.        Type 'key'  means press the specified
  7.                    key without 'Enter'.
  8.        Press  F?   means press  the  specified
  9.                    function key without 'Enter'.
  10.        Enter       means type in the  specified
  11.                    text and followed by 'Enter' key.
  12.        Select/Use an option:
  13.            use   cursor  keys  to  move   the
  14.            highlighted  option and  press  'Enter',  or
  15.            type the upper-cased character on the left.
  16.        GAF is not case sensitive, use either upper  or
  17.            lower cased key.
  18.  
  19.  
  20. Using The Menu
  21.   The  GAF  system menu bar, at the top of the  screen,
  22.   is  the  primary user interface to the  system.   The
  23.   system menu bar contains following menu items:  File,
  24.   Run,  Display,  Option, Adapt, Method,  Segment,  and
  25.   Help.   Use the first character of each menu item  or
  26.   use  cursor  keys (right/left arrows) to  select  the
  27.   menu  item.  When a menu item is selected a pull down
  28.   menu  appears  to  provide  function  selection.   To
  29.   select a function item in a pull down menu either  by
  30.   the  character on the left of that item or  move  the
  31.   cursor  with  up/down arrow keys  and  then  "Enter".
  32.   When  a  function item is selected, further secondary
  33.   menu  selection or data entry dialog may be  provided
  34.   by   that  function.   Except  rule  selection,   all
  35.   secondary  menus  and  data entry  dialog  boxes  are
  36.   displayed  immediately beneath the  pull  down  menu.
  37.   GAF  uses rule text window for rule selection.  Press
  38.   ESC  in  pull down menu or secondary menu will return
  39.   to  system  menu  bar.  Press ESC under  system  menu
  40.   will  bring  up the Run pull down menu,  except  when
  41.   the  system menu was ESCaped from any of the  running
  42.   mode  (i.e.  from  adapting or  simulation).   Please
  43.   refer  GAF.DOC for details.  The following steps  are
  44.   typical  for  function selection under simulation  or
  45.   adapting.
  46.        press "ESC" to escape back to system menu
  47.        select desired function menu (see above)
  48.        select desired function (see above)
  49.        press "ESC" again under system menu to go back
  50.  
  51. Introduction
  52.   This  simple example demonstrates the application  of
  53.   the  fuzzy  logic  to control a motor  based  on  its
  54.   angular position feedback.  Lets assume that this  is
  55.   a  robot arm, and its arm extension limit (in angular
  56.   position)  is from 0 degree to 70 degree.   The  demo
  57.   contains following segments:
  58.      Control    robotarm.gaf
  59.      Feedbackrobotarm.dat
  60.      Evaluation robotarm.evl
  61.      Reference  robotarm.ref
  62.   The  control  segment uses a set of  fuzzy  rules  to
  63.   control  the  motor.  The inputs to the control  loop
  64.   are  angular position of the arm, position error, and
  65.   angular  speed  of  the arm.   The  output  from  the
  66.   control segment is the current to the motor.
  67.   
  68.   The  feedback segment uses a set of data to  emulaste
  69.   the  reaction  of the robot arm (the  motor  and  its
  70.   sensors).   Outputs  of the feedback  loop  are:  the
  71.   angular  position and the angur speed  of  the  robot
  72.   arm.   Note  that  there  is a second  example  using
  73.   fuzzy  rules  to  emulate the  feedback  loop  please
  74.   refer to the file robotarm.fbk for details.
  75.   
  76.   The   reference   segment  calculates   the   angular
  77.   position error and generates a flag POS_REG  for  the
  78.   above two segments.  This flag is used to enable  the
  79.   segment  or part of its logic.  The reference segment
  80.   can be scheduled in a lower rate if so desired.
  81.   
  82.   The  evaluation  segment evaluates the  control  loop
  83.   for  the  application.   Based  on  fuzzy  rules   it
  84.   calculates  the EVAL_RESULT output variable  for  the
  85.   automatic adaptation.
  86.  
  87.  
  88. Simulation
  89.  
  90.   Run Simulation
  91.      After  start  the  demo, GAF displays  the  system
  92.      menu  at  the top of the screen.  Select run  menu
  93.      by  typing 'R', then select "simulation  mode"  by
  94.      either  type  'S' or move high lighted  cursor  to
  95.      "simulation   mode"  and  press  'Enter'.    After
  96.      simulation  mode  is selected,  GAF  displays  the
  97.      control  segment on the screen and waits for  user
  98.      input.   Please  refer to GAF.DOC for  details  of
  99.      the  display  windows.   Type  'F'  to  start  the
  100.      simulation.  You  should see the  trend  plots  of
  101.      inputs and outputs on the right and the rules  and
  102.      firing status on the left of the screen.
  103.  
  104.   Initialize the system
  105.      Press  function key F7 to initialize  the  system.
  106.      The  system reset is defined by the INITIALIZATION
  107.      declaration  in all segments of the system.   Type
  108.      'F' again to run the simulation.
  109.  
  110.   View the feedback loop
  111.      Now  switch  to the feedback loop by pressing  F3,
  112.      the  screen displays the feedback segment.   Press
  113.      F7  to  initialize the system, and then type  'F'.
  114.      Now  watch the plot of the inputs and the  outputs
  115.      for the feedback loop.
  116.  
  117.   Stepping through
  118.      Let's  switch back to the control loop by pressing
  119.      F3  three  times, and initialize it  by  F7.   Now
  120.      press  'Enter'  to see the demo program  goes  one
  121.      step.   The program allows you to do one  step  by
  122.      'Enter' or multiple steps by typing 2 to 9, or  10
  123.      steps  by  typing  '0'.  Type '0'  and  watch  the
  124.      program  goes through 10 steps and note  different
  125.      rules  are fired.  At any time type 'F' will bring
  126.      you to the end of the plot frame.
  127.      
  128.   Continuous mode
  129.      Press  'C'  to  run  the simulation  continuously.
  130.      You  can  stop  continuous mode  by  pressing  'C'
  131.      again  or ESCape (press ESC) back to system  menu.
  132.      While  in  continuous mode press F7 to  initialize
  133.      the system.
  134.  
  135.   Change variable value
  136.      Stop  continuous mode by pressing 'C'.  Now  let's
  137.      change  the  simulation from raising  the  arm  to
  138.      lowering  the  arm.   Press F7  and  then  ESC  to
  139.      escape  back to system menu.  Press 'S' to  select
  140.      segment  menu.   The segment menu  allows  you  to
  141.      switch  segment and change characteristics of  the
  142.      segment.   Switch to feedback segment by selecting
  143.      "segment number" under segment menu, or use F3  to
  144.      switch.   When  using Segment  menu  to  select  a
  145.      segment,  GAF  displays all  segment  names  in  a
  146.      secondary  menu and prompt for selection.   Select
  147.      segment  menu again, and select "set input value".
  148.      GAF  pops all inputs in a menu beneath the segment
  149.      menu,  select "REFERENCE" input and enter its  new
  150.      value to 0.  Select segment menu one more time  to
  151.      change the input variable "POSITION" value  to  70
  152.      (from  "set  input value").  Now get back  to  the
  153.      simulation  by pressing ESC, press  F3  to  switch
  154.      back  to control segment, and start simulation  by
  155.      stepping  through  it.   Note that  you  can  also
  156.      change  the  "POSITION"  value  from  the  control
  157.      segment (segment 0).
  158.  
  159.   View the plot
  160.      From  system menu type 'D' to select display menu.
  161.      The  display  menu  allows you  to  rearrange  the
  162.      display  windows.  Let's select "select plot  only
  163.      mode"  by  typing  '5', and then  escape  back  to
  164.      simulation.   GAF  should redraw the  screen  with
  165.      trend   plot  takes  most  of  the  screen.    Run
  166.      simulation by hiting F7 and then 'F'.
  167.  
  168.   View the combined result
  169.      From  Display  menu select "select  whole  display
  170.      mode".   The  right portion of the  screen  splits
  171.      into  two  parts, the upper half shows  the  plot,
  172.      and  the  lower half displays the combined  result
  173.      for  the  output.  The combined result  shows  the
  174.      trapezoid   result  of  all  fired  rules   (rules
  175.      generate  non-zero output).  Rerun the  simulation
  176.      by  pressing F7, and then 'F'.  Now, the  combined
  177.      result  tells you about the firing results of  all
  178.      rules  and the defuzzified crisp output  from  all
  179.      fired rules.
  180.  
  181.   View details about the fuzzy inference
  182.      The  above  exercise only allows you to  view  the
  183.      combined  result of the output.  GAF  also  allows
  184.      you  to  examine the firing details of the  rules.
  185.      This  feature along with the stepping mode is  the
  186.      best  way  to tuneup or debug the control  system.
  187.      From   the  segment  menu,  select  "display  rule
  188.      firing",  GAF highlights the first rule  by  using
  189.      the  left  column  of the text window.   Use  down
  190.      arrow  key to move to rule 5 and press 'Enter'  to
  191.      select  it.   Go  back  to the simulation,  you'll
  192.      find  the selected rule's fuzzy sets are displayed
  193.      to  the  left of the combined result.   Note  that
  194.      each  fuzzy  set has the same color  as  the  text
  195.      window.   Try  previous  exercises  to  view   the
  196.      changes of the fuzzy rule firing status.
  197.  
  198.   Disable rules
  199.      GAF  allows  user to disable individual  rule  for
  200.      testing  fuzzy  segment.  Let's disable  rule  10,
  201.      this  will  effectively break the control  system.
  202.      Since  there  is  no  rule  to  respond  when  the
  203.      POS_ERROR  is  VERY_LARGE, so after  system  reset
  204.      (press  F7)  there  will be  no  output  from  the
  205.      control   segment.   From  segment   menu   select
  206.      "disable rule", GAF highlights the rule  ID  0  on
  207.      the  left of the text window.  Press 'End' to move
  208.      the   highlight  cursor  to  rule  10,  and   then
  209.      'Enter'.   Now restart the simulation by  pressing
  210.      ESC,  F7 then 'F'.  You should see the rule 10  is
  211.      marked  with  'X' to indicate it's been  disabled,
  212.      and   also  that  there  is  no  response  to  the
  213.      position of the robot arm.
  214.  
  215.   Enable rules
  216.      There  are  two options under segment  menu  allow
  217.      you  to  enable rule(s).  The "enable  all  rules"
  218.      option  enables  all rules in this  segment.   The
  219.      "enable  rule"  enables the  selected  rule.   So,
  220.      type 'A' under segment menu to enable rule 10.
  221.  
  222.   Change sampling rate
  223.      Another  important feature in GAF is that you  can
  224.      tune  your  system  by trying  different  sampling
  225.      rate  (or  cycle  time defined in  each  segment).
  226.      From  Option menu select "sim schedule rate",  GAF
  227.      prompts  for  new rate. Enter 0.2 (in second)  and
  228.      restart  the  simulation.  Please  refer  Schedule
  229.      Policy   section   in  GAF.DOC  for   details   of
  230.      different schduling mode.
  231.  
  232.   Increment/decrement sampling rate
  233.      An  easy way to change the simulated sampling rate
  234.      is  to  use the '+' and '-' keys.  Press '+'  each
  235.      time  will cause the sample rate to increase 0.005
  236.      second,  and  press '-' will decrease  the  sample
  237.      rate    by   0.005   second.    The   amount    of
  238.      increment/decrement (default is 0.005 second)  can
  239.      be  changed  through the Option menu's  "Increment
  240.      value"   option.   Now  put  the   simulation   in
  241.      continuous  mode by 'C', reset it by F7  and  then
  242.      use '+' and '-' keys to adjust the sample rate  to
  243.      find  out  what's  the  max  stable  rate  of  the
  244.      control loop.
  245.  
  246.   Change output gain
  247.      You  can  change  the  gain of  the  output,  from
  248.      segment  menu's  "set output  gain"  option.   The
  249.      default gain is 1.0.
  250.  
  251.   Check individual segment
  252.      This feature allows you to examine one segment  at
  253.      a   time.   Let's  examine  the  feedback   loop's
  254.      response  at a constant motor current.   Press  F3
  255.      once to switch to the feedback segment.  From  run
  256.      menu  select  "check segment".  Then from  segment
  257.      menu  change the value of input variable "CURRENT"
  258.      to  1.0.  Run the simulation by typing 'F' to  see
  259.      the response of constant current input.
  260.  
  261.   Getting online help
  262.      Press F1 to get online help.
  263.      
  264.   Display the system limits
  265.      Press F2 to see the system limits.
  266.      
  267.   View segment information
  268.      Press   F4   to   see  the  variable   definition,
  269.      initialization  and  normal functions,  and  other
  270.      information for the selected display segment.
  271.  
  272.   View symbol definition
  273.      Press  F5 to see the fuzzy set symbols' definition
  274.      for this segment.
  275.      
  276.   View preset definition
  277.      Press  F6  to view the preset definition for  this
  278.      segment.
  279.      
  280.   Set new plot time frame
  281.      The  default  plot frame period  is  five  seconds
  282.      (except  in  sim clock mode), this can be  changed
  283.      through display menu's "plot duration" option.
  284.      
  285.   View local variables
  286.      The  default display mode is to display  IN,  OUT,
  287.      and  INOUT variables, the LOCAL variables are  not
  288.      displayed.   Use  "display local variable"  option
  289.      in    display   menu   to   enable/disable   LOCAL
  290.      variables.
  291.      
  292.   Quit the program
  293.      Press   'Alt-Q'   to   quit  the   program   under
  294.      simulation or select "quit" option from run menu.
  295.  
  296. Adapting the Fuzzy Segment
  297.  
  298.   The  genetic  adapt  mode is  an  offline  adaptation
  299.   mode.    While   fuzzy  logic  mimics   the   human's
  300.   imprecise  reasoning,  the genetic  algorithm  mimics
  301.   the  evolution of the nature.  The genetic  algorithm
  302.   uses   randomization  techniques  to  reach   optimum
  303.   without  exhausting  searching through  the  solution
  304.   state   space.  Apply  genetic  algorithm  in   fuzzy
  305.   control  eliminates  problems associated  with  fuzzy
  306.   system.  GAF uses genetic algorithm to derive  proper
  307.   rules  and  fuzzy  sets from the initial  rules.   By
  308.   changing,   adding,   deleting   rules   and    fuzzy
  309.   membership  sets  of  the fuzzy system,  the  genetic
  310.   algorithm  automatically  adapts  and  optimizes  the
  311.   fuzzy control system.
  312.  
  313.   The   adapting  example  is  built  on  top  of   the
  314.   simulation example, by adding an evaluation  segment.
  315.   The   file   "robotarm.evl"  defines  the  evaluation
  316.   segment.
  317.  
  318.   Start Adapting
  319.      From  system menu, type 'R' to bring up run  menu.
  320.      Select  "adapt mode" by pressing 'A'.  GAF  starts
  321.      adapting   the  control  loop  and  displays   the
  322.      control  segment along with adapt  status  on  the
  323.      top of the screen.
  324.      
  325.   Pause every iteration
  326.      Press  Alt-P  to  halt  the  adapting  after  each
  327.      iteration.  When  an iteration is  completed,  GAF
  328.      displays the status (Iteration done: ...)  at  the
  329.      bottom  of  the  screen  and  prompts  for  input.
  330.      Press 'C' to continue next iteration.  Press  Alt-
  331.      C to switch to continuous mode.
  332.      
  333.   Pause every cycle
  334.      Press  Alt-A  to  halt  the  adapting  after  each
  335.      cycle.  When  a cycle is completed,  GAF  displays
  336.      the  status (Cycle done: ...) at the bottom of the
  337.      screen  and  prompts  for  input.   Press  'C'  to
  338.      continue  next cycle.  Press Alt-C  to  switch  to
  339.      continuous mode.
  340.      
  341.   Change size of gene pool
  342.      Press  'Esc'  while  in continuous  adapting,  GAF
  343.      brings  up the system menu.  Select adapt menu  by
  344.      type  'A'.   From  adapt  menu  select  'max  best
  345.      items',  and  enter a new pool  size.   This  will
  346.      change the number of genes will be saved by GAF.
  347.      
  348.   Change minimum score
  349.      Again,  from  adapt menu, select "minimum  score",
  350.      GAF  prompts  for new minimum value.   Enter  0.5,
  351.      this  tells  GAF to accept all evaluation  results
  352.      ,which  are  greater  or  equal  than  0.5.    The
  353.      default of the minimum score is 0.6.
  354.      
  355.   Change method weight
  356.      The  method  menu  provides user  to  control  the
  357.      algorithm  of genetic adaptation.  Select  "adding
  358.      rule"  from  method  menu, enter  0  for  its  new
  359.      weight.   With zero weight, GAF will not  generate
  360.      (adding) new rule into the control loop.
  361.      
  362.   Print the result
  363.      Select 'File' menu from the system menu, and  type
  364.      'A'  to generate report for all genes in the  gene
  365.      pool.    The   result  will  be   saved   in   the
  366.      adaptlog.rpt, as specified by "report file"  under
  367.      File menu, file of the current directory.
  368.      
  369.   Generate statistic report
  370.      Again  type  'S'  (generate  statistic  log)  from
  371.      'File' menu, GAF produces a statistic report  file
  372.      with the file name specified by 'statistic to'  at
  373.      the   bottom  of  the  menu.   The  log   includes
  374.      statistics   for  all  methods.   Based   on   the
  375.      statistic  you  may want to adjust the  weight  of
  376.      the methods.
  377.